package com.livesource.client.web.projectBacklog.edit;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.livesource.client.model.entry.ProjectClass;
import com.livesource.client.utilities.FormField;

/**
 * 
 * @Feature
 */
public class FeatureForm extends VerticalPanel {

	public static TextBox featureName = new TextBox();
	public static TextArea featureDescription = new TextArea();
	public static TextBox featurePriority = new TextBox();
	public static TextBox featureEstimate = new TextBox();
	public static StatusList featureStatus;

	public FeatureForm(ProjectClass feature) {

		this.setSpacing(10);

		this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

		HTML html = new HTML(
				"<b><font color='blue' size='3'>Feature</font></b> ");
		this.add(html);

		VerticalPanel vp = new VerticalPanel();
		vp.setBorderWidth(1);

		vp.add(storyForm(feature));

		this.add(vp);
	}

	public VerticalPanel storyForm(ProjectClass feature) {

		VerticalPanel vp = new VerticalPanel();
		vp.setSpacing(20);

		featureName.setWidth("500px");
		featureName.setValue(feature.getFeatureName());
		vp.add(FormField.getFormField("Name", featureName));

		featureDescription.setSize("500px", "80px");
		featureDescription.setValue(feature.getFeatureDescription());
		vp.add(FormField.getFormField("Description", featureDescription));

		String priority = null;
		if (feature.getPriority() != null) {

			priority = feature.getPriority().toString();
		}

		featurePriority.setWidth("50px");
		featurePriority.setValue(priority);
		vp.add(FormField.getFormField("Priority", featurePriority));

		String estimate = null;
		if (feature.getEstimate() != null) {

			estimate = feature.getEstimate().toString();
		}

		featureEstimate.setWidth("50px");
		featureEstimate.setValue(estimate);
		vp.add(FormField.getFormField("Estimate", featureEstimate));

		featureStatus = new StatusList(feature.getStatus());
		vp.add(FormField.getFormField("Status", featureStatus));

		vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		vp.add(new ButtonSave(feature));

		return vp;
	}
}
